9 typedef pair
<int,int> point
;
12 map
<point
, int> cache
;
15 // cout << "n: " << n.first << " " << n.second << endl;
16 if (cache
.count(n
) > 0){
17 //cout << "Retornando " << cache[n] << endl;
21 if (n
.second
< n
.first
) swap(n
.first
, n
.second
);
23 for (int k
=0; k
<p
.size()-1; ++k
){
24 if (p
[k
]<=n
.first
&& n
.first
<=p
[k
+1] &&
25 p
[k
]<=n
.second
&& n
.second
<=p
[k
+1]){
27 //cout << "Retornando 0" << endl;
33 for (int k
=0; k
<p
.size(); ++k
){
34 if (n
.first
<p
[k
] && p
[k
]<n
.second
){
35 int q
= n
.second
- n
.first
+ f(point(n
.first
, p
[k
])) + f(point(p
[k
], n
.second
));
36 //cout << "q es: " << q << endl;
42 //cout << "min es: " << min << endl;
44 //cout << "Retornando " << min << endl;
51 while (cin
>> l
&& l
> 0){
58 for (int i
=1; i
<=n
; ++i
){
61 cout
<< "The minimum cutting is " << f(point(0, l
)) << ".\n";